What is @walletconnect/types?
@walletconnect/types is a TypeScript package that provides type definitions for the WalletConnect protocol. It is used to ensure type safety and consistency when developing applications that integrate with WalletConnect.
What are @walletconnect/types's main functionalities?
Session Types
Defines the structure of a WalletConnect session, including details about the peer, permissions, and expiry.
import { SessionTypes } from '@walletconnect/types';
const session: SessionTypes.Created = {
topic: 'abc123',
relay: { protocol: 'waku' },
peer: { metadata: { name: 'Example DApp', description: 'An example decentralized application', url: 'https://example.com', icons: ['https://example.com/icon.png'] } },
permissions: { blockchain: { chains: ['eip155:1'] }, jsonrpc: { methods: ['eth_sendTransaction'] } },
expiry: 1234567890
};
Proposal Types
Defines the structure of a WalletConnect proposal, including details about the proposer and required namespaces.
import { ProposalTypes } from '@walletconnect/types';
const proposal: ProposalTypes.Struct = {
id: 1,
params: {
proposer: { publicKey: '0xabc123', metadata: { name: 'Example DApp', description: 'An example decentralized application', url: 'https://example.com', icons: ['https://example.com/icon.png'] } },
requiredNamespaces: { eip155: { methods: ['eth_sendTransaction'], chains: ['eip155:1'], events: ['accountsChanged'] } }
}
};
Error Types
Defines the structure of error types used in WalletConnect, including error codes and messages.
import { ErrorTypes } from '@walletconnect/types';
const error: ErrorTypes.Provider = {
code: 4001,
message: 'User rejected the request.'
};
Other packages similar to @walletconnect/types
web3
web3.js is a collection of libraries that allow you to interact with a local or remote Ethereum node using HTTP, IPC, or WebSocket. It provides functionalities for interacting with smart contracts, sending transactions, and more. Unlike @walletconnect/types, which focuses on type definitions for WalletConnect, web3.js provides a comprehensive set of tools for Ethereum development.
ethers
ethers.js is a library for interacting with the Ethereum blockchain and its ecosystem. It provides utilities for sending transactions, interacting with smart contracts, and more. While @walletconnect/types provides type definitions for WalletConnect, ethers.js offers a full suite of tools for Ethereum development, including wallet management and contract interaction.
web3modal
web3modal is a library that allows developers to easily integrate multiple wallet providers into their applications. It provides a modal for users to select their preferred wallet. While @walletconnect/types focuses on type definitions for WalletConnect, web3modal provides a user interface for connecting to various wallet providers, including WalletConnect.